package com.sgcc.fj.pmos.e_fj_home.presenter;


import com.sgcc.fj.pmos.common.base.BasePresenter;
import com.sgcc.fj.pmos.common.http.HttpInterConst;
import com.sgcc.fj.pmos.common.http.HttpRequestUtils;
import com.sgcc.fj.pmos.common.http.MvpNetCallback;
import com.sgcc.fj.pmos.e_fj_home.bean.UserTypeHistoryBean;
import com.sgcc.fj.pmos.e_fj_home.contract.UserHistoryContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;


public class UserHistoryPresenter extends BasePresenter<UserHistoryContract.View> implements UserHistoryContract.Presenter {


    @Override
    public void getHistoryList(String mktYear,boolean isShowInvalidRecord) {
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> data = new HashMap<>();

        data.put("mktYear", mktYear);
//        data.put("mktYear", 2022);
        data.put("isShowInvalidRecord", !isShowInvalidRecord);
        params.put("data", data);

        Map<String, Object> pageInfo = new HashMap<>();
        pageInfo.put("pageNum", 1);
        pageInfo.put("pageSize", 20);
        params.put("pageInfo", pageInfo);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.HOME_USERTYPE_CHANGE_HIS, new MvpNetCallback<UserTypeHistoryBean>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
                getView().queryFaile();
            }

            @Override
            public void onResponse(UserTypeHistoryBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().querySuccess(response);
            }
        });
    }




}
